package com.woniu.controller;

import org.springframework.ui.Model;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("login")
public class LoginController {
    @RequestMapping("")
    public ModelAndView login(ModelAndView modelAndView){
        //对应yml的两个配置
        //1.前缀 classpath:/templates/
        //2.后缀 .html
        //最终效果,去/templates/login.html 渲染到浏览器
        modelAndView.setViewName("login");
        modelAndView.addObject("msg","--蜗牛学苑");
        return modelAndView;
    }
    //SpringMVC 9大执行过程 面试常用
    @RequestMapping("/show")
    public String login(Model model){
        //对应yml的两个配置
        //1.前缀 classpath:/templates/
        //2.后缀 .html
        //最终效果,去/templates/login.html 渲染到浏览器
        model.addAttribute("msg","蜗牛学苑");
        return "login";
    }
}
